package com.rbs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.rbs.entity.CustDistrict;
import com.rbs.mapper.CustDistrictMapper;
import com.rbs.service.ICustDistrictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 地区表 服务实现类
 * </p>
 *
 * @author lisl
 * @since 2024-04-07
 */
@Service
public class CustDistrictServiceImpl extends ServiceImpl<CustDistrictMapper, CustDistrict> implements ICustDistrictService {
    @Autowired
    private CustDistrictMapper custDistrictMapper;

    @Override
    public boolean findSameDistrictname(CustDistrict custDistrict) {
        LambdaQueryWrapper<CustDistrict> wrapper=new LambdaQueryWrapper<CustDistrict>().eq(CustDistrict::getCdStrdistrict,custDistrict.getCdStrdistrict());
        boolean flag=custDistrictMapper.exists(wrapper);
        return flag;
    }

    @Override
    public List<CustDistrict> findDistrictName(CustDistrict custDistrict) {
        LambdaQueryWrapper<CustDistrict> wrapper=new LambdaQueryWrapper<CustDistrict>().like(custDistrict.getCdStrdistrict()!=null,CustDistrict::getCdStrdistrict,custDistrict.getCdStrdistrict());
        List<CustDistrict> list=custDistrictMapper.selectList(wrapper);
        return list;
    }

}
